<?php

require_once('../../auth/auth.php');

//get values from POST
	$title=$_POST['title'];    
	$firstname=$_POST['first_name'];    
 	$lastname=$_POST['last_name']; 
 	$created = $_POST['created_on'];   
	$userType=$_POST['userType'];    
	$activeStatus=$_POST['activeStatus'];
	$login_id=$_POST['login_id']; 
	$password1=$_POST['password1']; 
	$password2=$_POST['password2']; 			 
	
		
include 'db_Connect.php';

	$username_exists_query = "SELECT user_id FROM User WHERE login_id='".$login_id."'";
	$username_exists_results = mysql_query($username_exists_query);
	$username_exists=mysql_num_rows($username_exists_results);  
	
	if($username_exists==0){

		$account = "INSERT INTO User 
					(title, first_name, last_name, created, user_type, active_status, login_id, password)
				VALUES
		         ('$title', '$firstname', '$lastname', '$created', '$userType', '$activeStatus', '$login_id', '".SHA1($password1)."')";
		echo $account;
		$result = mysql_query($account);
		
		if($result){
			echo("Account successfully created");
		} else{
			echo("Account create failed");
		}
		} else {
			echo("Username already exists");
}

include 'db_Close.php';



?>

